package jupitermouse.site.wordcount

import org.apache.flink.api.scala.ExecutionEnvironment

object BatchWCScalaApp {

  def main(args: Array[String]): Unit = {

    val inputPath = "file:///E:\\workroom\\learn\\flink\\demo_flink\\doc\\word.txt"

    val env = ExecutionEnvironment.getExecutionEnvironment

    val datasource = env.readTextFile(inputPath)

    // 引入隐式转换
    import org.apache.flink.api.scala._

    datasource.flatMap(_.toLowerCase.split(" "))
      .filter(_.nonEmpty)
      .map((_, 1))
      .groupBy(0)
      .sum(1)
      .print()
  }
}
